package com.toman.bean;

import android.app.Activity;
import android.text.InputType;

import com.toman.Enum.NetworkEnum;
import com.toman.Enum.TimeEnum;
import com.toman.Enum.ViewTypeEnum;
import com.toman.JavaBean.ImageObject;
import com.toman.camera.Camera;

import java.io.Serializable;
import java.sql.Time;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created by 邹苏隆 on 2018/11/5.
 * description：
 */
@Data
//@AllArgsConstructor
@NoArgsConstructor
public class TemplateInfBean implements Serializable {
    private List<ItemListBean> itemListBeans;
    //    传给服务器的字段名
    private String name;
    //    字段左边的title
    private String title;
    /*字段是否必须*/
    private boolean necessary = false;
    //    有值的时候
    private String content;
    //    上传服务器的数值
    private String result;
    //    布局类型
    private ViewTypeEnum type;
    //    发送服务器的参数列表
   private Map<String, String> map = new HashMap<String, String>();
//   需要获取的参数
private List<String> list_keys=new ArrayList<>();
//   服务器拿到的值

    private List<String> list_get=new ArrayList<>();

    //前置条件
    private List<TemplateInfBeanPreHandler> preHandlers = new ArrayList();

    //    是否顶上去
    boolean isMarginTop;
    //    是否可以编辑
    boolean edit;
//    输入类型
    private int inputType;
//监听器
    private List<TemplateInfBean> listeners = new ArrayList<>(1);

    //    接口类型
    private NetworkEnum network;

    private String companyId;
    private TimeEnum timeEnum;
    private Camera camera;
//    照片列表
    private List<ImageObject> problemImageList;
    private Activity activity;

    //文本
    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.necessary = necessary;
    }

    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, int inputType, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.inputType = inputType;
        this.necessary = necessary;
    }

    //网络点击
    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, NetworkEnum network, String companyId, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.network = network;
        this.companyId = companyId;
        this.necessary = necessary;
    }

    //本地点击
    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, List<ItemListBean> itemListBeans, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.necessary = necessary;
        this.itemListBeans = itemListBeans;
    }

    //    时间
    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, TimeEnum timeEnum, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.timeEnum = timeEnum;
        this.necessary = necessary;
    }

    //图片
    public TemplateInfBean(String name, String title, String content, String result, ViewTypeEnum type, List<ImageObject> problemImageList, Activity activity, boolean isMarginTop, boolean edit, boolean necessary) {
        this.name = name;
        this.title = title;
        this.content = content;
        this.result = result;
        this.type = type;
        this.isMarginTop = isMarginTop;
        this.edit = edit;
        this.problemImageList = problemImageList;
        this.activity = activity;
        this.necessary = necessary;
    }

    public void doAction(TemplateInfBean observable, TemplateInfBean listener) {

    }

    public void trigger() {
        for (TemplateInfBean listener : listeners) {
            listener.doAction(this, listener);
        }
    }
}
